package qianting.news.wemedia.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import qianting.news.apis.models.article.dtos.ArticleCommentDto;
import qianting.news.apis.models.article.dtos.CommentConfigDto;
import qianting.news.apis.models.comment.dtos.CommentLikeDto;
import qianting.news.apis.models.comment.dtos.CommentManageDto;
import qianting.news.apis.models.comment.dtos.CommentRepaySaveDto;
import qianting.news.common.entity.State;
import qianting.news.wemedia.service.CommentManageService;

@RestController
@RequestMapping("/comment")
@Api(tags = "评论管理")
public class CommentManageController {

    @Autowired
    private CommentManageService commentManageService;

    //查询指定文章的所有评论
    @PostMapping("/list")
    @ApiOperation(value = "查询指定文章的所有评论")
    public State list(@RequestBody CommentManageDto dto){
        return commentManageService.list(dto);
    }

    @ApiOperation(value = "删除评论")
    @DeleteMapping("/del_comment/{commentId}")
    public State delComment(@PathVariable("commentId") String commentId){
        return commentManageService.delComment(commentId);
    }

    @ApiOperation(value = "删除评论回复")
    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    public State delCommentRepay(@PathVariable("commentRepayId") String commentRepayId){
        return commentManageService.delCommentRepay(commentRepayId);
    }

    //查询当前用户可以评论的文章
    @ApiOperation(value = "查询当前用户可以评论的文章")
    @PostMapping("/find_news_comments")
    public State findNewsComments(@RequestBody ArticleCommentDto dto){
        return commentManageService.findNewsComments(dto);
    }

    @ApiOperation(value = "打开或关闭评论")
    @PostMapping("/update_comment_status")
    public State updateCommentStatus(@RequestBody CommentConfigDto dto){
        return commentManageService.updateCommentStatus(dto);
    }

    @ApiOperation(value = "对指定评论进行回复")
    //对指定评论进行回复
    @PostMapping("/comment_repay")
    public State saveCommentRepay(@RequestBody CommentRepaySaveDto dto){
        return commentManageService.saveCommentRepay(dto);
    }

    @ApiOperation(value = "喜欢评论")
    @PostMapping("/like")
    public State like(@RequestBody CommentLikeDto dto){
        return commentManageService.like(dto);
    }

}